<?PHP 
//¸ÄdemoµÄ¹¦ÄÜÊÇÈº·¢¶ÌÐÅºÍ·¢µ¥Ìõ¶ÌÐÅ¡££¨´«Ò»¸öÊÖ»úºÅ¾ÍÊÇ·¢µ¥Ìõ£¬¶à¸öÊÖ»úºÅ¼ÈÊÇÈº·¢£©

//Äú°ÑÐòÁÐºÅºÍÃÜÂë»¹ÓÐÊÖ»úºÅ£¬ÌîÉÏ£¬Ö±½ÓÔËÐÐ¾Í¿ÉÒÔÁË

//Èç¹ûÄúµÄÏµÍ³ÊÇutf-8,Çë×ª³ÉGB2312 ºó£¬ÔÙÌá½»¡¢
//Çë²Î¿¼ 'content'=>iconv( "UTF-8", "gb2312//IGNORE" ,'ÄúºÃ²âÊÔ¶ÌÐÅ[XXX¹«Ë¾]'),//¶ÌÐÅÄÚÈÝ
session_start();
$flag = 0; 
        //ÒªpostµÄÊý¾Ý 
		
$mobile = $_POST['name'];//¸öÊÖ»úºÅÓÃÓ¢ÎÄ¶ººÅ¸ô¿ª


$password=rand(0,999999);
$cod ="您的验证代码为:".$password; 
$cod.="【外卖365】";
$_SESSION['phoneCheck'] = $password;

$argv = array( 
         'sn'=>'SDK-BBX-010-17628', ////Ìæ»»³ÉÄú×Ô¼ºµÄÐòÁÐºÅ
		 'pwd'=>strtoupper(md5('SDK-BBX-010-17628'.'9-39[0-[')), //´Ë´¦ÃÜÂëÐèÒª¼ÓÃÜ ¼ÓÃÜ·½Ê½Îª md5(sn+password) 32Î»´óÐ´
		 'mobile'=>$mobile,//ÊÖ»úºÅ ¶à¸öÓÃÓ¢ÎÄµÄ¶ººÅ¸ô¿ª postÀíÂÛÃ»ÓÐ³¤¶ÈÏÞÖÆ.ÍÆ¼öÈº·¢Ò»´ÎÐ¡ÓÚµÈÓÚ10000¸öÊÖ»úºÅ
		 'content'=>iconv( "UTF-8", "gb2312//IGNORE" ,$cod),//¶ÌÐÅÄÚÈÝ
		 'ext'=>'',		
		 'stime'=>'',//¶¨Ê±Ê±¼ä ¸ñÊ½Îª2011-6-29 11:09:21
		 'rrid'=>''
		 ); 
//var_dump($argv);

//¹¹ÔìÒªpostµÄ×Ö·û´® 
foreach ($argv as $key=>$value) { 
          if ($flag!=0) { 
                         $params .= "&"; 
                         $flag = 1; 
          } 
         $params.= $key."="; $params.= urlencode($value); 
         $flag = 1; 
          } 
         $length = strlen($params); 
         
//         var_dump($params);
         
                 //´´½¨socketÁ¬½Ó 
        $fp = fsockopen("sdk2.zucp.net",80,$errno,$errstr,10) or exit($errstr."--->".$errno); 
         //¹¹ÔìpostÇëÇóµÄÍ· 
         $header = "POST /webservice.asmx/mt HTTP/1.1\r\n"; 
         $header .= "Host:sdk2.zucp.net\r\n"; 
         $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; 
         $header .= "Content-Length: ".$length."\r\n"; 
         $header .= "Connection: Close\r\n\r\n"; 
         //Ìí¼ÓpostµÄ×Ö·û´® 
         $header .= $params."\r\n"; 
         //·¢ËÍpostµÄÊý¾Ý 
         fputs($fp,$header); 
         $inheader = 1; 
          while (!feof($fp)) { 
                         $line = fgets($fp,1024); //È¥³ýÇëÇó°üµÄÍ·Ö»ÏÔÊ¾Ò³ÃæµÄ·µ»ØÊý¾Ý 
                         if ($inheader && ($line == "\n" || $line == "\r\n")) { 
                                 $inheader = 0; 
                          } 
                          if ($inheader == 0) { 
                                // echo $line; 
                          } 
          } 
		  //<string xmlns="http://tempuri.org/">-5</string>
	       $line=str_replace("<string xmlns=\"http://tempuri.org/\">","",$line);
	       $line=str_replace("</string>","",$line);
		   $result=explode("-",$line);
		  // echo $line."-------------";
		    if(count($result)>1)
			echo '·¢ËÍÊ§°Ü·µ»ØÖµÎª:'.$line.'¡£Çë²é¿´webservice·µ»ØÖµ¶ÔÕÕ±í';
			else
			echo 'send success!:'.$line;  
?>
